package com.chen.gcode.fx.controllers;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.AnchorPane;
import javafx.stage.DirectoryChooser;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MainController  implements Initializable {

    @FXML
    private TabPane tabPane;

    @FXML
    public void onclick(ActionEvent e){
        DirectoryChooser directoryChooser=new DirectoryChooser();
        File file = directoryChooser.showDialog(null);
        String path = file.getPath();//选择的文件夹路径


    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        System.out.println("dx");


        {
            Tab makeGCodeTab = new Tab();
            makeGCodeTab.setText("制作");
            try {

                AnchorPane makeGCodePane =  FXMLLoader.load(getClass().getClassLoader().getResource("makegcode.fxml"));
                makeGCodeTab.setContent(makeGCodePane);
            } catch (IOException e) {
                e.printStackTrace();
            }

            tabPane.getTabs().add(makeGCodeTab);
        }

        {
            Tab wdGCodeTab = new Tab();
            wdGCodeTab.setText("微雕转换");
            try {

                AnchorPane wdpane = FXMLLoader.load(getClass().getClassLoader().getResource("wdgcode.fxml"));
                wdGCodeTab.setContent(wdpane);
            } catch (IOException e) {
                e.printStackTrace();
            }

            tabPane.getTabs().add(wdGCodeTab);
        }

        {
            Tab settingTab = new Tab();
            settingTab.setText("设置");
            try {


                AnchorPane settingPane = FXMLLoader.load(getClass().getClassLoader().getResource("setting.fxml"));
                settingTab.setContent(settingPane);
            } catch (IOException e) {
                e.printStackTrace();
            }

            tabPane.getTabs().add(settingTab);
        }



    }
}
